﻿using LuDragon.Common.Constant;
using LuDragon.Common.Extensions;
using LuDragon.Data.Entities;
using LuDragon.IService.System;
using LuDragon.Web.Areas.Admin.Filters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Web;
using System.Web.Mvc;

namespace LuDragon.Web.Areas.Admin.Controllers
{
    [CheckLogin]
    public class LogController : BaseController
    {
        private ILogService _logService;

        public LogController(ILogService logService)
        {
            _logService = logService;
        }

        /// <summary>
        /// 日志列表
        /// </summary>
        /// <returns></returns>
        public ActionResult LogList()
        {

            return View();
        }

        /// <summary>
        /// 获取日志列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public ActionResult GetLogList(PageQueryParameter query)
        {
            Expression<Func<Sys_Logs, bool>> where = s => true;
            if (!string.IsNullOrWhiteSpace(query.WhereJson))
            {
                where = ExpressionExtension<Sys_Logs>.CreateExpression(query.WhereJson);
            }
            int count = 0;
            var list = _logService.GetByWhereWithPage(where, query.PageIndex, query.PageSize, out count, query.SortName, query.SortOrder).ToList();
            return PageQuerySucess(count, list);
        }


    }
}